<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">

<ui:composition template="/_template.xhtml">
	<ui:define name="content">
		<h:form>
			<fieldset>
			    <legend>Consultar Documentos</legend>				
				<p:inputText id="search-query" value="#{listaDocumentoManagedBean.chave}"/>
				<p:commandButton id="pesquisar" value="Pesquisar" action="#{listaDocumentoManagedBean.pesquisar}" >
					<f:ajax render="@all"/>
				</p:commandButton>
					
			</fieldset>		
			<p:dataTable value="#{listaDocumentoManagedBean.dataModel}"
				var="documento" paginator="true" rows="5" dynamic="true">

				<p:column headerText="Nome">
					#{documento.nome}
				</p:column>

				<p:column headerText="Descricao">
					#{documento.descricao}
				</p:column>
				
				<p:column headerText="Data Inclusão">
					<h:outputText value="#{documento.dataInclusao}" >
						<f:convertDateTime pattern="dd/MM/yyyy"></f:convertDateTime>
					</h:outputText>
				</p:column>
				
				<p:column>					
					<h:commandLink action="#{documentoManagedBean.alterar(documento)}" value="Alterar" />															
				</p:column>
				<p:column>
					<a  href="javascript:confirmacao#{documento.id}.show()">Remover</a>
					<p:dialog width="500" height="300" widgetVar="confirmacao#{documento.id}">
						<h:outputText value="Deseja excluir o documento #{documento.descricao}?" /><br/>
						<h:commandLink action="#{listaDocumentoManagedBean.remover(documento)}" value="Confirmar" />
					</p:dialog>
				</p:column>
				
			</p:dataTable>
		</h:form>
	</ui:define>
</ui:composition>


</html>